//
//  MyInfoViewController.m
//  ForengnMenu
//
//  Created by @-@ on 16/1/14.
//  Copyright © 2016年 余旺. All rights reserved.
//

#import "MyInfoViewController.h"

@interface MyInfoViewController ()

@property float maxX;

@property float minN;

@end

@implementation MyInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //设置最大滑动值
    self.maxX = 255.0f;
    
    self.minN = 0;
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setImage:[UIImage imageNamed:@"headImage.jpg"] forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 0, 30, 30);
    button.layer.cornerRadius = button.frame.size.height/2.0f;
    button.layer.masksToBounds = YES;
    
    [button addTarget:self action:@selector(headAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button];
    
    UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
    
    [self.navigationController.view addGestureRecognizer:pan];
    
    
}


-(void)headAction{
    
    //动画块
    [UIView animateWithDuration:0.3 animations:^{
        
        CGRect rect = self.navigationController.view.frame;
        
        if (rect.origin.x == self.maxX) {
            rect.origin.x = 0.0f;
        }else{
            rect.origin.x = self.maxX;
        }
        self.navigationController.view.frame = rect;
    
    }];
    
}


//平移
-(void)panAction:(UIGestureRecognizer *)pan{
    
    //动画块
    [UIView animateWithDuration:0.3 animations:^{
        
        CGRect rect = self.navigationController.view.frame;
        
        if (rect.origin.x == self.maxX) {
            rect.origin.x = 0.0f;
        }else{
            rect.origin.x = self.maxX;
        }
        self.navigationController.view.frame = rect;
    }];

}



@end
